public subroutine Grid2vectorFloat(grid, vector)
return an array 1D of numbers different than nodata
in a grid_real
Arguments
Type |
Intent | Optional | Attributes |
|
Name |
|
type(grid_real),
|
intent(in) |
|
|
:: |
grid |
|
real(kind=float),
|
intent(out), |
|
ALLOCATABLE
|
:: |
vector(:) |
|
Variables
Type |
Visibility | Attributes |
|
Name |
| Initial | |
integer(kind=short),
|
public |
|
:: |
count |
|
|
|
integer(kind=short),
|
public |
|
:: |
i |
|
|
|
integer(kind=short),
|
public |
|
:: |
istat |
|
|
|
integer(kind=short),
|
public |
|
:: |
j |
|
|
|
Source Code
SUBROUTINE Grid2vectorFloat &
!
(grid, vector)
IMPLICIT NONE
!Arguments with intent in
TYPE (grid_real), INTENT(IN) :: grid
!Arguments with intent out
REAL (KIND = float), INTENT (OUT), ALLOCATABLE :: vector (:)
!local declarations:
INTEGER (KIND = short) :: i, j, count, istat
!---------------------end of declarations--------------------------------------
!count number of actual values in grid, skip nodata
count = 0
DO i = 1, grid % idim
DO j = 1, grid % jdim
IF (grid % mat (i,j) /= grid % nodata) THEN
count = count + 1
END IF
END DO
END DO
!allocate vector
ALLOCATE (vector (count), STAT = istat)
!fill in vector
count = 0
DO i = 1, grid % idim
DO j = 1, grid % jdim
IF (grid % mat (i,j) /= grid % nodata) THEN
count = count + 1
vector (count) = grid % mat (i,j)
END IF
END DO
END DO
RETURN
END SUBROUTINE Grid2vectorFloat